package com.teacher.mobile.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.teacher.common.CommonResult;
import com.teacher.pojo.dto.notice.NoticeAddDto;
import com.teacher.pojo.dto.notice.NoticeDto;
import com.teacher.pojo.dto.notice.NoticeUpdateDto;
import com.teacher.pojo.vo.notice.NoticeVo;
import com.teacher.service.INoticeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 通知类型  申请拼车通知 拼车审批通知 评论通知 通用通知
 * </p>
 *
 * @author jiangzhuohang
 * @since 2024-03-14
 */
@RestController
@RequestMapping("/notice")
@Api(tags = "通知接口")
public class NoticeController {


    @Autowired
    private INoticeService iNoticeService;


    @ApiOperation("前台获取系统通知列表")
    @GetMapping("/getSysNotice")
    public CommonResult getSysNotice(){
        return iNoticeService.getSysNotice();
    }



    @ApiOperation("后台获取通知列表(分页) ")
    @GetMapping("/getNotice")
    public CommonResult getNotice(NoticeDto pageVo){
        IPage<NoticeVo> noticePageData = iNoticeService.getNoticePageData(pageVo);
        return CommonResult.success(noticePageData);
    }


    @PostMapping("addNotice")
    @ApiOperation("添加通知 ")
    public CommonResult addNotice(@RequestBody NoticeAddDto dto) {
        return iNoticeService.addNotice(dto);
    }

    @GetMapping("readNotice")
    @ApiOperation("把通知改为已读 ")
    public CommonResult readNotice(Long noticeId) {
        return iNoticeService.readNotice(noticeId);
    }

    @DeleteMapping("/deleteNoticeById")
    @ApiOperation("通过通知 id批量删除通知 ")
    public CommonResult deleteNoticeById(@RequestBody List<Long> list) {
        return  iNoticeService.deleteNotice(list);
    }
    @PutMapping("/updateNoticeById")
    @ApiOperation("通过通知id修改通知 ")
    public CommonResult updateNoticeById(@RequestBody NoticeUpdateDto updateDto) {
        return iNoticeService.updateNotice(updateDto);
    }

}

